package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightInterface;
import com.ktgj.flight.service.IFlightInterfaceService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 自动出票接口配置Controller
 * 
 * @author ruoyi
 * @date 2021-11-10
 */
@ControllerAdvice
@RestController
@RequestMapping("/interface")
public class FlightInterfaceController extends BaseController
{
    @Autowired
    private IFlightInterfaceService flightInterfaceService;

    /**
     * 查询自动出票接口配置列表
     */
    //@PreAuthorize(hasPermi = "flight:interface:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightInterface flightInterface)
    {
        startPage();
        List<FlightInterface> list = flightInterfaceService.selectFlightInterfaceList(flightInterface);
        return getDataTable(list);
    }

    /**
     * 导出自动出票接口配置列表
     */
    //@PreAuthorize(hasPermi = "flight:interface:export")
    @Log(title = "自动出票接口配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightInterface flightInterface) throws IOException
    {
        List<FlightInterface> list = flightInterfaceService.selectFlightInterfaceList(flightInterface);
        ExcelUtil<FlightInterface> util = new ExcelUtil<FlightInterface>(FlightInterface.class);
        util.exportExcel(response, list, "自动出票接口配置数据");
    }

    /**
     * 获取自动出票接口配置详细信息
     */
    //@PreAuthorize(hasPermi = "flight:interface:query")
    @GetMapping(value = "/{interfaceId}")
    public AjaxResult getInfo(@PathVariable("interfaceId") Integer interfaceId)
    {
        return AjaxResult.success(flightInterfaceService.selectFlightInterfaceById(interfaceId));
    }

    /**
     * 新增自动出票接口配置
     */
    //@PreAuthorize(hasPermi = "flight:interface:add")
    @Log(title = "自动出票接口配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightInterface flightInterface)
    {
        return toAjax(flightInterfaceService.insertFlightInterface(flightInterface));
    }

    /**
     * 修改自动出票接口配置
     */
    //@PreAuthorize(hasPermi = "flight:interface:edit")
    @Log(title = "自动出票接口配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightInterface flightInterface)
    {
        return toAjax(flightInterfaceService.updateFlightInterface(flightInterface));
    }

    /**
     * 删除自动出票接口配置
     */
    //@PreAuthorize(hasPermi = "flight:interface:remove")
    @Log(title = "自动出票接口配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{interfaceIds}")
    public AjaxResult remove(@PathVariable Integer[] interfaceIds)
    {
        return toAjax(flightInterfaceService.deleteFlightInterfaceByIds(interfaceIds));
    }
}
